<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('OKR信息列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list hidden">
                    <ul>
                        <li>
                            <label>排序编号：</label>
                            <input type="text" name="sortId"/>
                        </li>
                        <li>
                            <label>编号：</label>
                            <input type="text" name="rowCode"/>
                        </li>
                        <li>
                            <label>内容描述：</label>
                            <input type="text" name="content"/>
                        </li>
                        <li>
                            <label>类型：</label>
                            <select name="rowType" th:with="type=${@dict.getType('okr_row_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>信心指数：</label>
                            <input type="text" name="confidenceStar"/>
                        </li>
                        <li>
                            <label>用户标识：</label>
                            <input type="text" name="userId"/>
                        </li>
                        <li>
                            <label>目标评分：</label>
                            <input type="text" name="scoreStar"/>
                        </li>
                        <li>
                            <label>父级ID：</label>
                            <input type="text" name="parentId"/>
                        </li>
                        <li>
                            <label>周期ID：</label>
                            <input type="text" name="cycleId"/>
                        </li>
                        <li class="hidden">
                            <label>周期类型：</label>
                            <input type="text" name="cycleType"  id="cycleType"/>
                        </li>
                        <li>
                            <label>目标进度：</label>
                            <input type="text" name="process"/>
                        </li>
                        <li>
                            <label>状态：</label>
                            <select name="status" th:with="type=${@dict.getType('row_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>优先级：</label>
                            <input type="text" name="priority"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-info" id="expandAllBtn">
                <i class="fa fa-exchange"></i> 展开/折叠
            </a>
            <div class="btn-group"  th:each="cycle : ${cycleList}">
                <a class=""th:classappend="${cycle.cycleType == 0} ? 'btn btn-primary' : 'btn btn-info' "      th:text="${cycle.cycleName}"    th:value="${cycle.cycleName}"   th:onclick="'changeCycleType('+${cycle.cycleType}+')'"></a>
            </div>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-tree-table" ></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var cycleFlag = [[${@permission.hasPermi('okr:cycle:useList')}]];
    var rowTypeDatas = [[${@dict.getType('okr_row_type')}]];
    var removeFlag = [[${@permission.hasPermi('okr:info:remove')}]];
    var scoreStarDatas = [[${@dict.getType('ork_fraction')}]];
    var statusDatas = [[${@dict.getType('row_status')}]];
    var priorityDatas = [[${@dict.getType('okr_level')}]];
    var prefix = ctx + "okr/synergy";
    $(function() {
        var options = {
            code: "rowId",
            parentCode: "parentId",
            uniqueId: "id",
            expandAll: true,
            expandFirst: false,
            url: prefix + "/list",
            search:true,
            modalName: "协同OKR",
            striped:true,
            columns: [{
                field: 'selectItem',
                radio: true
            },
                {
                    field: 'rowCode',
                    width: '10%',
                    title: '编号',
                    formatter: function(value, row, index) {
                        var rowNo = '';
                        if(row.rowType==0){
                            rowNo = '<span>O'+value+'</span>';
                        }
                        else {
                            rowNo = '<span>KR'+value+'</span>';
                        }
                        return rowNo;
                    }
                },
                {
                    title: 'OKR描述',
                    field: 'content',
                    width: '50%',
                    class:true,
                    cellStyle: function(value, row, index) {
                        return { css: { "word-break": "break-all","word-wrap": "break-word","white-space":"pre-wrap" } };
                    }
                },
                {
                    field: 'loginName',
                    width: '5%',
                    title: '用户'
                },
                {
                    field: 'deptName',
                    width: '5%',
                    title: '部门'
                },
                {
                    field: 'rowType',
                    width: '5%',
                    title: '类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(rowTypeDatas, value);
                    }
                },
                {
                    field: 'confidenceStar',
                    title: '信心指数',
                    width: '5%',
                    formatter: function(value, row, index) {
                        return  '<span class="badge badge-success">'+value+'</span>';
                    }
                },
                {
                    field: 'scoreStar',
                    title: '目标评分',
                    width: '5%',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(scoreStarDatas, value);
                    }
                },
                {
                    field: 'process',
                    title: '目标进度',
                    width: '5%',
                    formatter: function(value, row, index) {
                        return  '<span class="badge badge-success">'+value+'</span>';
                    }
                },
                {
                    field: 'priority',
                    title: '优先级',
                    width: '5%',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(priorityDatas, value);
                    }
                },
                {
                    title: '操作',
                    width: '5%',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.treeTable.init(options);




    });


    function changeCycleType(type){
        $("#cycleType").val(type);
        $.treeTable.search();
    }

</script>
</body>
</html>